package com.yohann.boot.config.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;


/**
 * rabbit mq 监听器
 *
 * @author Yeung Wah
 * @since 2021/9/12
 */
@Component
@ConditionalOnBean(ConnectionFactory.class)
public class RabbitMqListener {

    @RabbitListener(queues = "${rabbit.mq.dead.letter.queue}")
    public void receive(Message message, Channel channel) {
        System.out.println(new String(message.getBody()));
    }
}